# _*_ coding:utf-8 _*_

#@Time :2021/3/20 

# @Author : litao

# @File : main.py

import asyncio
from utils.LoggerUtil import InitLog, logger
from utils.RequestUtil import RequestUtil
from app import orm
# from app.models import
from AutoUpdateService.conf import config as conf

PyRedisUrl = 'http://qdsoft.huaguangsoft.com/QdbomCache/AllDesData'
JavaRedisUrl = 'http://qdsoft.huaguang.soft.com/hgsoft_base/Qdbom/AllDesData/'

class RedisData:
    def __init__(self, ip, requesttype):
        self.ip = ip
        self.requesttype = requesttype

    def request(self):
        if self.requesttype == 'POST':
            pass
        else:
            pass

    def getdata(self, url, argv):
        resp = RequestUtil.requestpost(self.ip + url, argv)
        return resp.content

async def GetJavaQdsoftidList():
    # 获取java数据库工厂列表
    qdsoftiddictlist = await orm.select("SELECT DISTINCT corpInfoId from hg_corpinfo", ())
    JavaQdsoftidList = [qdsoftiddict['corpInfoId'] for qdsoftiddict in qdsoftiddictlist]
    return JavaQdsoftidList

async def GetRedisQdsoftidList():
    #获取缓存服务器工厂列表
    return RedisQdsoftidList

async def main():
    await orm.create_pool(**conf.configs['db'])
    #1.获取redis 数据的主类别子类别
    JavaQdsoftidList = await GetJavaQdsoftidList()
    logger.info('factorys={}'.format(JavaQdsoftidList))

    #argv = {'qdsoft'}
    #RequestUtil.requestpost(redisurl, argv)
    #2.获取mysql 数据的主类别子类别
if __name__ == '__main__':
    InitLog(conf.log_path)    #初始化日志系统，根据info,error,debug 将日志输出到不同文件夹
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())    #main函数来进行解析数据
